// 万象page
require(['./components/swiper', 'backbone', './plugins/swiper.animate'], function(Swiper, Backbone) {

	var WxView = Backbone.View.extend({
		el: '#app',
		initialize: function() {
			this.renderEls();
			this.initSwiper();
		},
		events: {
			'click [data-idx]': 'evt_swiperToPage'
		},
		renderEls: function() {
			this.els = {
				swiperContainer: this.$('#j_wx_swiper')
			}
		},
		initSwiper: function() {
			this.wxSwiper = new Swiper({
				el: this.els.swiperContainer,
				direction: 'vertical',
				onInit: function(swiper) {
					swiperAnimateCache(swiper); //隐藏动画元素
					swiperAnimate(swiper); //初始化完成开始动画
				},
				onSlideChangeEnd: function(swiper) {
					swiperAnimate(swiper);
				}
			});
		},
		evt_swiperToPage: function(e) {
			var idx = $(e.currentTarget).data('idx');
			this.wxSwiper && this.wxSwiper.swiper.slideTo(idx);
		}
	});
	return new WxView();
});